package cn.iocoder.yudao.module.member.dal.mysql.profit;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.controller.admin.profit.vo.ProfitPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.profit.ProfitDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Date;

@Mapper
public interface ProfitMapper extends BaseMapperX<ProfitDO> {
   default   Long countTotal(String startDate){
        return selectCount(new LambdaQueryWrapperX<ProfitDO>().like(ProfitDO::getCreateTime, startDate));
    }

    default PageResult<ProfitDO> selectPage(ProfitPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProfitDO>()
                .eqIfPresent(ProfitDO::getType, reqVO.getType())
                .eqIfPresent(ProfitDO::getPrice, reqVO.getPrice())
                .eqIfPresent(ProfitDO::getCostPrice, reqVO.getCostPrice())
                .eqIfPresent(ProfitDO::getProfit, reqVO.getProfit())
                .eqIfPresent(ProfitDO::getYear, reqVO.getYear())
                .eqIfPresent(ProfitDO::getMonth, reqVO.getMonth())
                .like(ProfitDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProfitDO::getId));
    }
}
